package com.byzx.wine.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.byzx.wine.po.Syauthority;
import com.byzx.wine.service.ISyauthorityService;

@RequestMapping("/authority")
@Controller
public class AuthorityAction {
	@Autowired
	private ISyauthorityService syauthorityService;
	
	
	@RequestMapping("index")
	public String login(HttpServletResponse response, HttpServletRequest request) {
		return "authority/Authority";
	}
	
	@RequestMapping("selectAuthority")
	@ResponseBody
	public Map<String, Object> findAuthority(){
		List<Map<String, Object>> list = syauthorityService.findSyauthority();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		return map;
	}
	
	@RequestMapping("deleteAuthority")
	@ResponseBody
	public Map<String,Object> deleteByPrimaryKey(Integer id){
		Map<String, Object> map = new HashMap<String, Object>();
		Integer i = syauthorityService.deleteByPrimaryKey(id);
		map.put("i", i);
		return map;
	}
	
	
	@RequestMapping("updateAuthority")
	@ResponseBody
	public Map<String,Object> selectData(Integer id){
		Map<String, Object> map = new HashMap<String, Object>();
		Syauthority record = syauthorityService.selectByPrimaryKey(id);
		map.put("record", record);
		return map;
	}
	
	@RequestMapping("updateData")
	@ResponseBody
	public Map<String,Object> updateByPrimaryKey(Syauthority record){
		Map<String, Object> map = new HashMap<String, Object>();
		Integer i = syauthorityService.updateByPrimaryKey(record);
		map.put("i", i);
		return map;
	}
		
	
	@RequestMapping("insertAuthority")
	@ResponseBody
	public Map<String,Object> addSyuser(Syauthority record){
		Map<String, Object> map = new HashMap<String, Object>();
		Integer i = syauthorityService.insert(record);
		map.put("i", i);
		return map;
	}
	
	
	
}
